﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage2.master" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient"  %>
<script runat="server">
    
    protected void Page_Load()
    {

        string conStr = @"Data Source=ADMIN-PC\SQLEXPRESS;Initial Catalog=graduate_manage;Integrated Security=True";  
      
      SqlConnection connection = new SqlConnection(conStr);
      SqlCommand cmd = connection.CreateCommand();
      connection.Open();

      cmd.CommandText = " SELECT  COUNT(*)  FROM EMPLOYINFO_GRADUATE";
      SqlDataReader reader = cmd.ExecuteReader();

      reader.Read();
      
      int countWorkcha = reader.GetInt32(0); 
      connection.Close();//否则下一步不能重新读

      connection.Open();

      string year = "2011";
     //string year = Session["selelctyear"].ToString();
      cmd.CommandText = "SELECT EMPLOY_WORKCHA,COUNT(*) AS COUNT_WORKCHA " +
      "  FROM EMPLOYINFO_GRADUATE,INFO_GRADUATE" +
      " WHERE EMPLOYINFO_GRADUATE.GRA_ID=INFO_GRADUATE.GRA_ID AND GRA_GRATIME=" + "'" + year + "-06-07'" +
       "GROUP BY EMPLOYINFO_GRADUATE.EMPLOY_WORKCHA ";
       

     
      reader = cmd.ExecuteReader();
      int []perc = new int[countWorkcha];
      string [] workcha = new string[countWorkcha];
      int i=0;
      while (reader.Read())
      {
          workcha[i] = reader.GetString(0);
          perc[i] = (reader.GetInt32(1) *100)/ countWorkcha;   
          i++;   
      }
      int workcha_count = i;
      connection.Close();

      Series series = new Series("series1");
      series.ChartType = SeriesChartType.Pie;
      int j =0;
      for( ; j<i;j++)
      {
          
          series.Points.AddY(perc[j]);
          series.Points[j].AxisLabel = workcha[j];
          series.Points[j].Label = workcha[j] + ":"+ perc[j].ToString()+"%";
          series.Points[j].ToolTip =workcha[j];//+"(职工总数："+countWorkcha.ToString()+")"
      }
      series.YAxisType = AxisType.Primary;
      series.YValueType = ChartValueType.Int32;
      Chart1.Series.Add(series);
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">

    <table style="width: 500px; height : 220px;">
        <tr>
            <td style="width: 500px; height : 160px;">
                <asp:Label ID="Label7" runat="server" Text=" " CssClass = "PieLable"></asp:Label>
                <asp:Chart ID="Chart1" runat="server" Height="350px " Palette="SemiTransparent" 
                    style="margin-right: 49px" Width="500px" >
                    <Series>
                  
               
                    </Series>
                    <ChartAreas>
                        <asp:ChartArea Name="ChartArea1" BackImageWrapMode="TileFlipY" 
                            BackSecondaryColor="Transparent">
                            <AxisY ArrowStyle="Lines">
                                <LabelStyle Interval="Auto" />
                            </AxisY>
                            <AxisX ArrowStyle="Lines" InterlacedColor="Black">
                            </AxisX>
                        </asp:ChartArea>
                    </ChartAreas>
                    <Legends>
                        <asp:Legend HeaderSeparatorColor="Orange" Name="Legend1" ShadowOffset="3">
                        </asp:Legend>
                    </Legends>
                    <Titles>
                       <asp:Title  Name="Title1" Text="毕业生就业方向饼状图"   
                            ForeColor="Black" Font="隶书, 12pt"  >
                        </asp:Title>
                    </Titles>

<BorderSkin SkinStyle="Emboss"></BorderSkin>
                </asp:Chart>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    
</asp:Content>

